<template>
	<web-view :src="webViewUrl"  @message="onMessage" @onPostMessage="onMessage" class="boxWrapper" 
	:style="{ height: `calc(100vh - ${statusBarHeight}px)` }" ></web-view>
	 
</template>

<script> 
import store from "@/store";
import {H5_URL} from '@/config/app';
import {
	toLogin,
	checkLogin
} from '@/libs/login';
import i18n from '@/utils/lang.js';
export default {
	data() {
		return { 
			webViewUrl:'',
			statusBarHeight: uni.getSystemInfoSync().statusBarHeight || 20
		}
	},
	onLoad(options) {
		// uni.showLoading({ title: '加载中', mask: true });
		  setTimeout(() => uni.hideLoading(), 2000); // 模拟加载完成
		  uni.hideLoading()
		uni.setNavigationBarColor({ 
		  backgroundColor: '#151515'
		});
		
		this.id = options.id || '';
		console.log('id',this.id);
		if (!store.state.app.token && !checkLogin()) {
			toLogin();
			return false;
		}
		//小程序向H5传参带在url后面
		this.webViewUrl = H5_URL + '/#/pages/official?token='+store.state.app.token+'&id='+ this.id;
	},
	onShow(){
		
	},
	methods:{
		onMessage(e){//接收回调参数
		console.log('data1',e);
	
		}
	},
} 
</script>

<style scoped>
	/* 覆盖整个页面背景 */
	.boxWrapper {
	  background-color: #151515 !important;
	  height: 100vh;
	}
 
</style>

<style>
	page{
		 background-color: #151515!important;
		 min-height: 100vh;
	}
	/* 隐藏原生 Loading 界面（仅 H5 有效） */
	uni-web-view .uni-web-view--loading {
	  background-color: #151515!important
	}
</style>